/* radio buttons? */
$(document).ready(function(){
	$('ul.radio[id*=radio_]').each(function(){
		var name = this.id.replace('radio_','');
		var value = Radio.get(name);
		Radio.set(name,value);
	});
});
var Radio = {
	set:function(name,value){
		var currentValue = Radio.get(name);
		var $radio = $('input[type=radio][name='+name+'][value='+value+']');
		if(Modal.isOpen()){
			var $radio = $('#pp_full_res').find('input[type=radio][name='+name+'][value='+value+']');
		}
		$radio.prop('checked',true);
		if(currentValue != value){
			$radio.change();
		}
		Radio.reflect(name);
	},
	get:function(name){
		var $radio = $('input[type=radio][name='+name+']:checked');
		if(Modal.isOpen()){
			$radio = $('#pp_full_res').find('input[type=radio][name='+name+']:checked');
		}
		var value = $radio.val() || "";
		
		return value;
	},
	getOptionName:function(name){ // returns the name of the option instead of the value (which may be uuid)
		var value = Radio.get(name);
		var text = $('ul#radio_'+name).find('input[value='+value+']').attr('title');
		return text;
	},
	reflect:function(name){
		var $radios = $('ul#radio_'+name);
		if(Modal.isOpen()){
			$radios = $('#pp_full_res').find('ul#radio_'+name);;
		}
		$radios.find('li').removeClass('selected');
		var value = Radio.get(name);
		$radios.find('li[value='+value+']').addClass('selected');
	}
};